package com.dwx.guli.service.edu.controller.api;


import com.dwx.guli.service.base.result.R;
import com.dwx.guli.service.edu.entity.Teacher;
import com.dwx.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author dwx
 * @since 2021-06-30
 */
@Api(tags = "讲师")
@CrossOrigin
@RestController
@RequestMapping("/api/edu/teacher")
public class ApiTeacherController {
    @Autowired
    private TeacherService teacherService;
    @ApiOperation("所有讲师列表")
    @GetMapping("/list")
    public R list(){
        List<Teacher> list = teacherService.list();
        if(null!=list&&0<list.size()){
            return R.ok().data("items",list).message("获取讲师列表成功");
        }else {
            return R.error().message("获取讲师列表失败");
        }
    }
    @ApiOperation(value = "获取讲师")
    @GetMapping("get/{id}")
    public R get(
            @ApiParam(value = "讲师ID", required = true)
            @PathVariable String id) {
        Map<String, Object> map = teacherService.selectTeacherInfoById(id);
        return R.ok().data(map);
    }
}

